/*
* Copyright (c) 2011 Connection Road.  All rights reserved.
* This program and the accompanying material are made available
* under the terms of the Eclipse Public Licnese v1.0 which is
* available at http://www.eclipse.org/legal/epl-v10.html
*/

using System.Collections.Generic;

namespace CrSyncFilesUtils {

    public class CrSyncFileCountHolder {
        public CrSyncFileCountHolder() {
            Success = 0;
            Fail = 0;
        }

        /// <summary>
        /// Initialize a counter with a default values
        /// </summary>
        /// <param name="sucess">Success count</param>
        /// <param name="failed">Fail count</param>
        public CrSyncFileCountHolder(int sucess, int failed)
        {
            Success = sucess;
            Fail = failed;
        }

        public int Success { get; set; }
        public int Fail { get; set; }
        public int Total { get { return Success + Fail; } }

        /// <summary>
        /// Update counter by adding count holder object
        /// </summary>
        /// <param name="countHolder"></param>
        public void Add(CrSyncFileCountHolder countHolder)
        {
            Add(countHolder.Success,countHolder.Fail);
        }

        /// <summary>
        /// Update counter by adding a list count holder objects
        /// </summary>
        /// <param name="countHolders"></param>
        public void Add(List<CrSyncFileCountHolder> countHolders)
        {
            foreach (var countHolder in countHolders)
            {
                Success += countHolder.Success;
                Fail += countHolder.Fail;
            }
        }

        /// <summary>
        /// Update counter by adding success and fail count
        /// </summary>
        /// <param name="success">Success count. Defaults to 0.</param>
        /// <param name="fail">Fail count. Defaults to 0.</param>
        public void Add(int success, int fail)
        {
            Success += success;
            Fail += fail;
        }


    }
}
